package com.liang.cloudorder8081.controller;

import com.liang.cloudorder8081.feign.FeignProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: XIAOLIANG
 * Date: 2021/5/24
 * Time: 16:58
 * Description: No Description
 */
@RestController
@RequestMapping("/order")
public class TestController {

//    @Autowired
//    RestTemplate restTemplate;

    @Autowired
    FeignProductService feignProductService;

    @RequestMapping("/getOrder/{id}")
    public Map getOrder(@PathVariable("id") Integer id){
//        Map<String,Object> resultMap = new HashMap<>();
//        resultMap.put("code",10000);
//        resultMap.put("msg","查询订单成功");
//        resultMap.put("order",id);
//
//        ResponseEntity<Map> forEntity = restTemplate.getForEntity("http://localhost:8820/product/"+id, Map.class);

        Map order = feignProductService.getOrder(id);
//
//        int statusCodeValue = forEntity.getStatusCodeValue();
//        System.out.println("请求商品服务的状态码: " + statusCodeValue);
//        Map body = forEntity.getBody();
        System.out.println("商品服务返回值: " +order);


        return order;


    }


}
